<?php
if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_above_title.php'))
{
	include_once(CHILDTEMPLATEPATH . '/my_account_above_title.php');
}
session_unregister('success_message_reg');
?>
	<?php 
	if($_REQUEST['type']=="editprofile")
	{ ?>
		<div class="breadcrumb clearfix">
        	<a href="<?php echo site_url(); ?>">Home</a>  
           	<a href="<?php echo site_url('?ptype=myaccount'); ?>"><?php _e(VIEW_ACCOUNT_PAGE_TITLE); ?></a>  
            <?php _e(EDIT_PROFILE_PAGE_TITLE); ?>
		</div>
	<?php 
	}else if($_REQUEST['type']=="address")
	{
		?>
        <div class="quick-cart">
<?php 
		$itemsInCartCount = $Cart->cartCount();
		$cartAmount = $General->get_amount_format($General->get_payable_amount());
?>
<ul>
	<li><label>Total Item(s) :</label> <?php echo $itemsInCartCount; ?></li>
   	<li><label>Total amount : </label><?php echo $cartAmount; ?></li>
</ul>
</div>
	<div class="new-breadcrumb">
			<span class="curve lt"></span>
			<span class="curve lb"></span>
		<ol>
    		<li class="one"><a href="<?php echo site_url('/?ptype=cart'); ?>">Checkout</a></li>
    		<li class="current three">Billing and shipping</li>
    		<li class="four">Select Payment</li>
    	</ol>
	</div>

        <?php
	}else{
		?>
        <div class="breadcrumb clearfix">
        	<a href="<?php echo site_url(); ?>">Home</a>  
            <?php _e(VIEW_ACCOUNT_PAGE_TITLE); ?>
		</div>
  <?php 
  }
	?>
    <?php
if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_after_title.php'))
{
	include_once(CHILDTEMPLATEPATH . '/my_account_after_title.php');
}
?>
<div>
<?php /*?>    <div class="fr"><?php $themeUI->get_logout_link($css='fr');?></div><?php */?>
		
        <?php  //AFFILIATE START
		if($General->is_active_affiliate())
		{
			global $current_user;
			get_currentuserinfo();
			$user_id = $current_user->data->ID;
			$user_role = get_usermeta($user_id,'wp_capabilities');
			if(!$user_role['affiliate'])
			{
			?>
				<h6><b><?php _e(WANT_TO_BECOME_AFF_TEXT);?> <?php $themeUI->get_affiliate_link($css='fr');?></b> </h6>
				<?php
			} 
			
		} //AFFILIATE END
		?>
      
        <?php
         if($_REQUEST['type']=="editprofile")
		 {?>
         <?php
		 	if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_above_edit_profile.php'))
			{
				include_once(CHILDTEMPLATEPATH . '/my_account_above_edit_profile.php');
			}
			include_once(TEMPLATEPATH . '/library/includes/edit_profile.php');
			if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_below_edit_profile.php'))
			{
				include_once(CHILDTEMPLATEPATH . '/my_account_below_edit_profile.php');
			}
		}else if($_REQUEST['type']=="address"){
		  	if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_above_edit_profile.php'))
			{
				include_once(CHILDTEMPLATEPATH . '/my_account_above_edit_profile.php');
			}
			include_once(TEMPLATEPATH . '/library/includes/edit_profile.php');
			if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_below_edit_profile.php'))
			{
				include_once(CHILDTEMPLATEPATH . '/my_account_below_edit_profile.php');
			}
		}else if($_REQUEST['type']=="addressconfirm"){
		  	if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_above_edit_profile.php'))
			{
				include_once(CHILDTEMPLATEPATH . '/my_account_above_edit_profile.php');
			}
			include_once(TEMPLATEPATH . '/library/includes/address.php');
			if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_below_edit_profile.php'))
			{
				include_once(CHILDTEMPLATEPATH . '/my_account_below_edit_profile.php');
			}
		}else
		{
			if(!$General->is_storetype_catalog())
			 {
				 if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_above_view_orders.php'))
				{
					include_once(CHILDTEMPLATEPATH . '/my_account_above_view_orders.php');
				}?>
				<div class="form-holder orders no-margin-t">
                 <?php
				 include_once(TEMPLATEPATH . '/library/includes/view_orders.php');


				if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_below_view_orders.php'))
				{
					include_once(CHILDTEMPLATEPATH . '/my_account_below_view_orders.php');
				}
				/*if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_above_view_downloads.php'))
				{
					include_once(CHILDTEMPLATEPATH . '/my_account_above_view_downloads.php');
				}
				 include_once(TEMPLATEPATH . '/library/includes/view_downloads.php');
				if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_below_view_downloads.php'))
				{
					include_once(CHILDTEMPLATEPATH . '/my_account_below_view_downloads.php');
				}*/
				?>
                
                </div>
                <?php
			 }
			global $current_user;
			$user_address_info = get_user_meta($current_user->data->ID,'user_address_info');
			?>
        <?php
			if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_above_billing_fields.php'))
			{
				include_once(CHILDTEMPLATEPATH . '/my_account_above_billing_fields.php');
			}
			?>
            <div class="personal-info fr">
            <h3 class="form-title"><?php _e(PERSONAL_INFO_TEXT);?></h3>
            <div class="form-details">
            <ul>
            	<li><?php _e(NAME_TEXT);?> : <strong><?php echo $userInfo['display_name'];?></strong></li>
            	<li><?php _e(EMAIL_TEXT);?> : <strong><?php echo $userInfo['user_email'];?></strong></li>
                <li>Password : <strong>**********</strong>
                <p>If you need to change your current password <a href="<?php echo site_url('/?ptype=myaccount&amp;type=editprofile&amp;change=1'); ?>">Click here</a></p>
                </li>
                </ul>
            </div>
            <?php
			global $wpdb,$Cart,$Product,$ord_db_table_name;
			$coupons =get_option('discount_coupons');
			$coupon_list;
			foreach ($coupons as $coupon) :
			if($coupon[coupon_type]=="private" && $coupon[coupon_user]!=$user_id ){
				$coupon_list .="";
			}else{
				if($coupon[dis_per]!="amt"){
					$coupon[dis_amt] = $coupon[dis_amt]."%";
				}else{
					$coupon[dis_amt] = "Rs ".$coupon[dis_amt];
				}
				if($coupon[cart_amt]=="" || $coupon[cart_amt]=="0"){
					$cart_msg = ', on any purchase.';
				}
				else{
					$cart_msg = 'on a minimum purchase of <strong>'.$coupon[cart_amt].'.</strong>';
				}
				if($coupon[coupon_visible]!="no"){
				$coupon_list.= '<li>Use <span>'.$coupon[couponcode].'</span> to get <strong>'.$coupon[dis_amt].'</strong> off '.$cart_msg.' Offer valid till <strong>'.$coupon[valid_date].'</strong></li>';
				}
			
			}
			endforeach;
			?>
            
            
            
            <?php if($coupon_list!=""){ ?>
            <div class="coupon-details">
            <h3><?php _e('Available Coupons'); ?></h3>
            <?php echo '<ul>'.$coupon_list.'<ul>'; ?>
            </div>
            <?php } ?>
        </div>
                    <div class="add-details">
            <div class="billing_add">
            <h3><?php _e('Billing Address') ; ?></h3>
            <ul>
  	            <li><label><strong><?php _e(NAME_TEXT);?> :</strong></label><p><?php echo $userInfo['display_name'];?></p></li>
            	<li><label><strong><?php _e(ADDRESS_TEXT);?> :</strong></label><p><?php echo $user_address_info[0]['user_add1'];?><br />
<?php echo $user_address_info[0]['user_add2'];?><br />
<?php echo $user_address_info[0]['user_city'];?><br />
<?php echo $user_address_info[0]['user_state'];?><br />
<?php echo $user_address_info[0]['user_country'];?>
</p></li>
            	<li><label><strong><?php _e(POSTAL_CODE_TEXT);?> :</strong></label><p><?php echo $user_address_info[0]['user_postalcode'];?></p></li>
            	<li><label><strong><?php echo PHONE_NUMBER_TEXT;?> :</strong></label><p><?php echo $user_address_info[0]['phone'];?></p></li>
            	<li><a href="<?php echo site_url('/?ptype=myaccount&amp;type=editprofile'); ?>" class="fl" >Click here to edit</a></li>

           <?php
			if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_after_billing_fields.php'))
			{
				include_once(CHILDTEMPLATEPATH . '/my_account_after_billing_fields.php');
			}
			?>
            </ul>
        </div>
        <div class="shipping-ad fl">
           <h3><?php _e('Shipping Address') ; ?></h3>
            <ul>
            	<li><label><strong><?php _e(NAME_TEXT);?> :</strong></label><p><?php echo $user_address_info[0]['buser_name'];?></p></li>
                <li><label><?php _e(ADDRESS_TEXT);?> :</label><p><?php echo $user_address_info[0]['buser_add1'];?><br />
                <?php echo $user_address_info[0]['buser_add2'];?><br />
                <?php echo $user_address_info[0]['buser_city'];?><br />
                <?php echo $user_address_info[0]['buser_state'];?><br />
                <?php echo $user_address_info[0]['buser_country'];?></p></li>
            	<li><label><strong><?php _e(POSTAL_CODE_TEXT);?> :</strong></label><p><?php echo $user_address_info[0]['buser_postalcode'];?></p></li>
            	<li><label><strong><?php echo PHONE_NUMBER_TEXT;?> :</strong> </label><p><?php echo $user_address_info[0]['bphone'];?></p></li>
            	<li><a href="<?php echo site_url('/?ptype=myaccount&amp;type=editprofile'); ?>" class="fl" >Click here to edit</a></li>
			</ul>
        </div>
        </div>
         <?php
			if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_above_affiliate_account.php'))
			{
				include_once(CHILDTEMPLATEPATH . '/my_account_above_affiliate_account.php');
			}
			?>
        <?php
		////////AFFILIATE CODING//////////
			if($General->is_active_affiliate())
			{
				@include_once(TEMPLATEPATH . '/library/includes/affiliates/affiliate_account.php');		
			}	
		}
		 ?>
		   <?php
			if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/my_account_below_affiliate_account.php'))
			{
				include_once(CHILDTEMPLATEPATH . '/my_account_below_affiliate_account.php');
			}
			?>
			</div>    